package com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_view;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter.DownloListViewPagerAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter.NoScrollViewPagerAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/8/8.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 *
 *
 * 下载列表 碎片
 */

public class DownloListFragment extends BaseFragment {

    private TabLayout talayout;
    private ViewPager viewpager;
    private DownloListViewPagerAdapter downloListViewPagerAdapter;

    @Override
    protected void initDate() {
        showTileTitleRlBg();
        showTilteBg();
        showTitleContent();
        showTileIvRight();
        //设备管理(6)
        setTitleContent("下载列表", 0xffffffff);
        setIvLeftRight(R.mipmap.share_and_download);
        List<Fragment> list = new ArrayList<>();
        list.add(new DwonlaodFragment());
        list.add(new DwonlaodCompleteFragment());
        downloListViewPagerAdapter = new DownloListViewPagerAdapter(getChildFragmentManager(),mContext,list);
        viewpager.setAdapter(downloListViewPagerAdapter);
        talayout.setupWithViewPager(viewpager);
        viewpager.setCurrentItem(0,false);
        //设置自定义视图
        for (int i = 0; i < talayout.getTabCount(); i++) {
            TabLayout.Tab tab = talayout.getTabAt(i);
            tab.setCustomView(downloListViewPagerAdapter.getTabView(i,talayout));
        }
    }
    @Override
    protected void cancellationControls() {
        if(talayout != null){
            talayout =null;
        }
        if(viewpager != null){
            viewpager = null;
        }
    }
    @Override
    protected View getChildFragmentView() {
        View view = View.inflate(mContext, R.layout.fragment_download_list,null);
        talayout = view.findViewById(R.id.fragment_download_list_talayout);
        viewpager = view.findViewById(R.id.fragment_download_list_viewpager);
        return view;
    }

    @Override
    protected void onClickedTvRight() {

    }

    @Override
    protected void onClickedIvRight() {

    }

    @Override
    protected void onClickedIvLeft() {

    }
}
